package xiaocao.learn.java.io.nio;

import java.nio.ByteBuffer;
import java.nio.CharBuffer;

public class ViewBuffersDemo {
	
	public static void main(String[] args) {
		ByteBuffer bb = ByteBuffer.wrap(new byte[]{0, 0, 0, 0, 0, 0, 0, 'a'});
		bb.rewind();
		while(bb.hasRemaining()) {
			System.out.print(bb.position() + " ->" + bb.get() + ",");
		}
		System.out.println();
		bb.rewind();
		CharBuffer cb = ((ByteBuffer)bb.rewind()).asCharBuffer();
		while(cb.hasRemaining()) {
			System.out.print(cb.position() + " ->" + cb.get() + ",");
		}
		System.out.println();
		 
		
	}

}
